import turtle

# 数据
def line(x1,x2, y1,y2):
    length = abs(y2-y1) if abs(y2-y1)>=abs(x2-x1) else abs(x2-x1)
    delta_x = (x2-x1)/length; delta_y = (y2-y1)/length
    k = 1
    x = x1; y = y1
    pts = []
    while k <= length+1:
        pts.append((x, y))
        k += 1
        x += delta_x; y += delta_y
    return pts

pts = line(-100,100, 26,-40)

# 创建画布
turtle.setup(600,600, 300,50)
turtle.pensize(2) # 画笔大小，为1时不成像，遂为2
turtle.speed(0)
turtle.pencolor("blue")

# 画图
turtle.up()
for pt in pts:
    turtle.goto(*pt)
    turtle.down()
    turtle.goto(*pt)
    turtle.up()

# 结束
turtle.hideturtle() # 隐藏画笔箭头
turtle.done()

